<?php
//Si pas de user connecté, on renvoie sur la page générale de la liste des concours

if(isset($_GET['userid']))
{
	$userConsulted = $userManager->get((int) $_GET['userid']);
}
else
{
	$userConsulted = $userConnected;
}
$listContests = $contestManager->getListContests(null,null,null,0,$userConsulted, 1);

?>

<div id="section_list_contests">
<table id="board" summary="mycontests_board" class="tab">
	<thead>
		<tr>
			<th id="statusContest_col">Statut concours</th>
			<th id="sport_col">Sport</th>
			<th id="event_col">Compétition</th>
			<th id="contestName_col">Concours</th>
			<th id="statusPlayer_col">Statut</th>
			<th id="nbPlayers_col">Nombre de joueurs</th>
			<th id="admin_col">Admin</th>
			<th id="creator_col">Créateur</th>
		</tr>
	</thead>
	<tfoot>
		<tr>
			<td colspan="8">Liste des concours</td>
		</tr>
	</tfoot>
	<tbody>
	<?php
	if(count($listContests) == 0)
	{
		?>
		<tr>
			<td colspan="8">Aucun concours</td>
		</tr>
		<?php
	}
	else
	{
		foreach($listContests as $contest)
		{
		?>
			<tr>
				<td><?php echo $contestManager->getStatus($contest);?></td>
				<td><?php echo $sportsManager->get((int) $sportsEventManager->get((int) $eventManager->get((int) $contest->event_id())->sportsEvent_id())->sport_id())->name();?></td>
				<td><?php echo $sportsEventManager->get((int) $eventManager->get((int) $contest->event_id())->sportsEvent_id())->shortName();?></td>
				<td><a href="contest.php?contestid=<?php echo $contest->id();?>" alt="Consulter ce concours"><?php echo $contest->name();?></a></td>
				<td><?php echo $userManager->getStatusPlayer($userConsulted, $contest)[1];?></td>
				<td><?php echo count($contestManager->getListPlayers($contest, 1));?></td>
				<td><?php if($userManager->isAdmin($userConnected, $contest)) echo "Oui"; else echo "Non"; ?></td>
				<td><?php echo $contestManager->getCreator($contest)->login();?></td>
			</tr>
		<?php
		}
	}
	?>
	</tbody>
</table>
</div>